<template>
	<view class="wrapper">
		<u-loading-page loadingColor="#e3230e" iconSize="40" :loading="!pageLoading"></u-loading-page>
		<view class="notice">
			<view class="notice-title">{{info?.noticeTitle}}</view>
			<view class="notice-other main-flex">
				<view class="notice-time">{{info?.createTime}}</view>
				<view class="notice-view main-flex">
					<uni-icons type="eye" size="14"></uni-icons>
					<text class="notice-view-count">{{info?.views}}</text>
				</view>
			</view>
			<view class="notice-content">
				<u-parse :content="info?.noticeContent || ''"></u-parse>
			</view>
		</view>
	</view>
</template>

<script setup>
import { computed, ref, watch } from 'vue';
import { onReady, onLoad, onReachBottom, onShow, onHide } from '@dcloudio/uni-app';
import useUserStore from '@/store/modules/user'
import useSetStore from '@/store/modules/set'
import { notice, noticeDetail } from "@/api/app_api/index"
import { timeFormat } from '@/uni_modules/uview-plus'
import modal from '@/plugins/modal'

	const userStore = useUserStore()
	const setStore = useSetStore()
	
	// 页面加载
	const pageLoading = ref(false)
	const id = ref('')
	const info = ref({})
	const getDetail = () => {
		noticeDetail({
			id: id.value
		}).then(res => {
			info.value = res.data
			pageLoading.value = true
			uni.setNavigationBarTitle({
				title: res?.data?.noticeTitle || '公告'
			})
		})
	}
	const getNotice = () => {
		notice({
			id: id.value
		}).then(res => {
			info.value = res.data
			pageLoading.value = true
			uni.setNavigationBarTitle({
				title: res?.data?.noticeTitle || '公告'
			})
		})
	}
	
	onLoad((option) => {
		if(option.id) {
			id.value = option.id
			getDetail()
		} else {
			getNotice()
		}
	})
	
</script>

<style lang="scss">
	.notice {
		padding: 20rpx;
		&-title {
			font-size: 32rpx;
			font-weight: 600;
			text-align: center;
		}
		&-other {
			margin-top: 20rpx;
			font-size: 24rpx;
			color: $text-light;
		}
		&-view {
			margin-left: auto;
			&-count {
				margin-left: 10rpx;
			}
		}
		&-content {
			font-size: 28rpx;
			margin-top: 20rpx;
		}
	}
</style>
